package edu.java.texbooks.tutorial.test02;

public class Textbook extends Book implements Cloneable{
    
    // --- Instance Variables --------------------------------------------------
    int classNumber=12;
    
    public Textbook() {
	this(0);
    } 
    
    public Textbook(int classNumber) {
	this.classNumber = classNumber;
    } 
    
    public Textbook(int isbn ,int classNumber) {
	super(isbn);
	this.classNumber = classNumber;
    }
    
    public Textbook(int isbn,int countPages ,int classNumber) {
	super(isbn,countPages);
	this.classNumber = classNumber;
    }

    // --- Getters and Setters -------------------------------------------------

   public int getClassNumber() {
        return classNumber;
    }

    public void setClassNumber(int classNumber) {
        this.classNumber = classNumber;
    }

    // --- Methods -------------------------------------------------------------
    
    // hiding (but not overriding)
    public static void printInfo(){
	System.out.println("Textbokk info");
    }
    
    // --- Override Methods ----------------------------------------------------
    
    @Override
    public Object clone()throws CloneNotSupportedException{
	Object obj=super.clone();
	((Textbook)obj).setClassNumber(22);
	return obj;
    }
    
    @Override
    public boolean equals(Object object){
	boolean isEqualClassNumber= this.getClassNumber()==((Textbook)object).getClassNumber();
	return super.equals(object)&& isEqualClassNumber;
    }
}
